const { Controller } = require('varal');

class RegionController extends Controller {
	async cascader() {
		const { parent_id = 0 } = this.app.fields;

		const serv = this.app.service('RegionService');
		return serv.cascader(parent_id).then((data) => {
			this.app.json({
				err_code: 0,
				data
			})
		}).catch((err) => {
			console.log(err);

			this.app.json({
				err_code: 1,
				err_msg: err.toString()
			})
		})
	}
}

exports = module.exports = RegionController;
